// 获取文章列表
import {useEffect, useState} from "react";
import {getArticleListAPI} from "@/apis";

function useArticleList(data) {
    // 接收文章列表数据
    const [articleList, setArticleList] = useState([])
    const [count, setCount] = useState(0)
    // 页面渲染完毕之后获取文章列表数据
    useEffect(() => {
        async function getArticleList() {
            const res = await getArticleListAPI(data)
            setArticleList(res.data.results)
            setCount(res.data.total_count)
        }

        getArticleList()
    }, [data]);

    return {
        articleList,
        count
    }

}

export default useArticleList